package cn.xt.service.user;

import cn.xt.bean.Users;
import cn.xt.dao.user.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImp implements UserService {
    @Autowired
    private UserDao userDao;

    /*登录*/
    @Override
    public Users login(String phone, String pwd) {
        return userDao.login(phone,pwd);
    }
    /*查询手机号是否存在*/
    @Override
    public Users yzphone(String phone) {
        return userDao.yzphone(phone);
    }
    /*注册用户*/
    @Override
    public int register(Users users) {
        try {
            return userDao.register(users);
        }catch (Exception e){
            e.printStackTrace();
        }
        return 0;
    }
    /*修改密码查询用户名是否讯在*/
    @Override
    public Users modifyByName(String name) {
        System.out.println(name+"=========");
        return userDao.modifyByName(name);
    }
    /*根据手机号修改密码*/
    @Override
    public int UpdatePassword(String pwd, String phone) {
        System.out.println("密码"+pwd+",电话"+phone);
        return userDao.UpdatePassword(pwd,phone);
    }
    /*修改用户头像*/
    @Override
    public boolean updaImage(String idPicPath,int users_id) {
        System.out.println("修改头像----"+idPicPath+",编号=="+users_id);
        return userDao.UpdImage(idPicPath,users_id);
    }
    /*修改用户手机号*/
    @Override
    public boolean UpdPhone(String phone,int user_id) {
        return userDao.UpdatePhone(phone,user_id);
    }

    @Override
    public boolean UpdateUser(Users users) {
        System.out.println("user==="+users);
        return userDao.UpdateUser(users);
    }

    @Override
    public Users user(int users_id) {
        return userDao.user(users_id);
    }
}
